Skip to content

plugin-askrene: cap dial iterations to avoid redundant solver runs - #9735

Open
aryarathoree wants to merge 1 commit into
ElementsProject:masterfrom
aryarathoree:fix-askrene-mu-cutoff
Open

aryarathoree wants to merge 1 commit into
ElementsProject:masterfrom
aryarathoree:fix-askrene-mu-cutoff

Conversation

@aryarathoree

@aryarathoree aryarathoree commented Nov 13, 2026 •

Copy link
Copy Markdown

Problem

As reported in #9726 by @ksedgwic, when no route fits maxfee, linear_routes() in plugins/askrene/child/mcf.c executes 28 solver runs before failing.

The 17 runs above (\mu = 0.95) (up to near_one = 1. - 1e-6) can take up to 10× longer on mainnet nodes without improving the found fees. This frequently causes callers with tight fee budgets (e.g. rebalancers) to hit askrene-timeout.

Solution

Cap near_one at 0.99. This limits the solver loop to at most 15 runs, cutting off the slow iterations with diminishing returns above (\mu = 0.95) and avoiding unnecessary timeouts.

Fixes #9726

Checklist

  • The changelog has been updated in the relevant commit(s) according to the guidelines (Changelog-Fixed:).
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked (#9726).
  • Important: All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade (N/A, internal heuristic).

Comment thread plugins/askrene/child/mcf.c Resolved
@Lagrang3

Copy link
Copy Markdown
Collaborator

Concept ACK.
Another possibility could be to change the function that increases the dials.
Right now we would double the dial and then renormalize.
We could do something that grows faster near the tails.

@aryarathoree

Copy link
Copy Markdown
Author

Thanks for the feedback!

I've addressed @Andezion's review by introducing const double max_mu = 0.99; while keeping near_one = 1. - 1e-6 so the flow_fee_adjustment fallback remains intact. I've also rebased on master.

@Lagrang3, I agree that increasing the step size near the tails makes sense, since (1 - μ) currently only halves at each iteration. However, runs above μ = 0.95 have diminishing returns, with fees rarely improving. Capping at max_mu = 0.99 keeps the fix minimal while limiting solver runs to at most 15.

Would you prefer to land this cap first, or should we adjust the dial step function directly in this PR?

@Andezion Andezion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run test_real_data and test_real_biases locally? Do their expected values still hold? Did you think about bigger steps above 0.95 instead of a hard cap (the other option in the issue)? For example, mu = 0.95, 0.99, 0.999 would still reach the cheaper solutions in 2-3 extra runs

Also should max_mu be a #define near SINGLE_PATH_THRESHOLD, or stay a local const? Local is fine for me, im only asking for consistency with #9723, which touches the same loop

Comment thread tests/test_askrene.py
# Dial iterations cut off once mu >= 0.99, bounding solver runs (issue #9726)
l1.daemon.logs_catchup()
mu_retries = [l for l in l1.daemon.logs if "retrying with mu of" in l]
assert 0 < len(mu_retries) <= 15

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

l1.daemon.wait_for_log(r"retrying with mu of 0\.993994")
assert len([l for l in l1.daemon.logs if "retrying with mu of" in l]) == 14

The retry loop around the solver in linear_routes() repeatedly doubles
the odds mu / (1 - mu) when the route fee exceeds maxfee. Previously,
the cut-off was set to `near_one = 1. - 1e-6`, requiring 27 retries
(28 solver runs) before failing.

As reported in ElementsProject#9726:
"The 17 added runs are at mu above 0.95, where a run is slower and the
fee found changes little or rises... Effect on a mainnet node that
rebalances with a tight fee budget, v26.06.10 against v26.06.9: the median
rebalance request takes 26 s against 5 s, and 12.8% of them end in the
timeout (askrene-timeout 30); none did before."

Introduce `max_mu = 0.99` to cap mu iterations while keeping
`near_one = 1. - 1e-6` for delay/hop dials and the flow_fee_adjustment
fallback. This bounds the maximum number of solver attempts to 15,
avoiding the diminishing-returns iterations above mu=0.95 where fee
priority is already ~99% and MCF solver passes become significantly
more expensive without improving found fees.

Fixes ElementsProject#9726

Changelog-Fixed: askrene: bound dial iterations to avoid redundant solver runs when fee exceeds budget.
@daywalker90
daywalker90 force-pushed the fix-askrene-mu-cutoff branch from 70226f7 to 9f5402e Compare November 26, 2026 15:37
@daywalker90

Copy link
Copy Markdown
Collaborator

There are some CI tests failures that don't appear to be flakes, please fix these.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

askrene: getroutes makes 28 solver runs when no route fits maxfee (11 before #9627)

4 participants